package serviceImpl

import (
	"fmt"
	"gin-ranking/common/util"
	"gin-ranking/common/zinx/tcp/lock/helper"
	tcpMsg "gin-ranking/common/zinx/tcp/lock/lockMessage"
	"github.com/duke-git/lancet/v2/datetime"
)

type Lock1010AwakeHandler struct{}

// CheckMd5Sign 校验签名
func (lc Lock1010AwakeHandler) CheckMd5Sign(message tcpMsg.TcpMessage) bool {
	return helper.DefaultCheckMd5Sign(&message)
}

// Handler 处理消息
func (lc Lock1010AwakeHandler) Handler(message tcpMsg.TcpMessage) tcpMsg.TcpMessage {

	// 解码解密
	originDataBytes := message.OriginBizDataBytes

	// 当前时间
	currentTime := util.BytesToUint64Big(util.StandardBefore(originDataBytes[0:4], 8))

	// 任务状态
	dataType := util.BytesToUint32Big(util.StandardBefore(originDataBytes[4:6], 4))

	// 锁版本号码
	firmwareVersion := util.ParseFirmwareVersion(originDataBytes[6:10])

	fmt.Printf("锁唤醒执行码：%d， 上报时间：%s，数据类型： %d，版本号：%s \n", message.ActionCode, datetime.NewUnix(int64(currentTime)).ToFormat(), dataType, firmwareVersion)

	return helper.BuildDefaultRequestData(message.LockId)
}
